#include "stdafx.h"
#include "CrossoverHelpers.h"
#include "stdlib.h"

#define AVOID_IF_STATEMENTS 1

double ProbSelect(double lfProb, double lfVal1, double lfVal2)
{
	static double lfRandScale = 1.0/((double)RAND_MAX);
	double lfRandVal = rand()*lfRandScale;

#if AVOID_IF_STATEMENTS
	return lfVal1 +(lfVal2-lfVal1)*(lfRandVal > lfProb);
#else
	if(lfRandVal > lfProb)
	{
		return lfVal2;
	}
	return lfVal1;
#endif

}